import web
import gcp
from session import AuthBase, need_auth

urls = (
        '/gcp/search', 'Search',
        '/gcp/printer/(.+)', 'Printer'
        )

app = web.application(urls, globals())

class Search(AuthBase):
    @need_auth
    def GET(self):
        session = self.getSession()
        cloudprint = gcp.GoogleCloudPrint(user=session.user)
        return cloudprint.search_printers()
       
class Printer(AuthBase):
    @need_auth
    def GET(self, printerid):
        session = self.getSession()
        cloudprint = gcp.GoogleCloudPrint(user=session.user)
        return cloudprint.get_printer_info(printerid)

if __name__ == '__main__':
    app.cgirun()
    

        

